package com.android.lovely.ui.widget

import android.content.Context
import android.util.AttributeSet
import android.widget.FrameLayout
import com.android.lovely.databinding.LayoutSplashLoginBinding
import com.android.lovely.databinding.WidgetRoleTipBinding
import com.kotlin.extensions.inflater.LayoutInflaterExt.layoutInflater

/**
 *
 * @author why
 * @date 2025/4/7 20:31
 */
class RoleTipWidget  @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) : FrameLayout(context, attrs, defStyleAttr) {

    private val mBinding by lazy {
        WidgetRoleTipBinding.inflate(layoutInflater, this, false)
    }

    private var listener: OnClickListener? = null

    init {
        addView(mBinding.root)

        mBinding.quick1.setOnClickListener { listener?.onClick("{{user}}") }
        mBinding.quick2.setOnClickListener { listener?.onClick("{{char}}") }
        mBinding.quick3.setOnClickListener { listener?.onClick(":") }
        mBinding.quick4.setOnClickListener { listener?.onClick("*") }
        mBinding.quick5.setOnClickListener { listener?.onClick(",") }
        mBinding.quick6.setOnClickListener { listener?.onClick(".") }
        mBinding.quick7.setOnClickListener { listener?.onClick("?") }
        mBinding.quick8.setOnClickListener { listener?.onClick("!") }
        mBinding.quick9.setOnClickListener { listener?.onClick("\"\"") }
        mBinding.quick10.setOnClickListener { listener?.onClick("...") }
        mBinding.quick11.setOnClickListener { listener?.onClick("~") }
    }

    fun setListener(listener: OnClickListener) {
        this.listener = listener
    }

    interface OnClickListener {
        fun onClick(text:String)
    }

}